home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / net / route.h < prev    next >
C/C++ Source or Header  |  1995-02-14  |  3KB  |  94 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * Copyright (c) 1980, 1986 Regents of the University of California.
  9.  * All rights reserved.
  10.  *
  11.  * Redistribution and use in source and binary forms are permitted
  12.  * provided that this notice is preserved and that due credit is given
  13.  * to the University of California at Berkeley. The name of the University
  14.  * may not be used to endorse or promote products derived from this
  15.  * software without specific prior written permission. This software
  16.  * is provided ``as is'' without express or implied warranty.
  17.  *
  18.  *    @(#)route.h    7.3 (Berkeley) 12/30/87
  19.  */
  20.  
  21. /*
  22.  * Kernel resident routing tables.
  23.  * 
  24.  * The routing tables are initialized when interface addresses
  25.  * are set by making entries for all directly connected interfaces.
  26.  */
  27.  
  28. /*
  29.  * A route consists of a destination address and a reference
  30.  * to a routing entry.  These are often held by protocols
  31.  * in their control blocks, e.g. inpcb.
  32.  */
  33. struct route {
  34.     struct    rtentry *ro_rt;
  35.     struct    sockaddr ro_dst;
  36. };
  37.  
  38. /*
  39.  * We distinguish between routes to hosts and routes to networks,
  40.  * preferring the former if available.  For each route we infer
  41.  * the interface to use from the gateway address supplied when
  42.  * the route was entered.  Routes that forward packets through
  43.  * gateways are marked so that the output routines know to address the
  44.  * gateway rather than the ultimate destination.
  45.  */
  46. struct rtentry {
  47.     u_long    rt_hash;        /* to speed lookups */
  48.     struct    sockaddr rt_dst;    /* key */
  49.     struct    sockaddr rt_gateway;    /* value */
  50.     short    rt_flags;        /* up/down?, host/net */
  51.     short    rt_refcnt;        /* # held references */
  52.     u_long    rt_use;            /* raw # packets forwarded */
  53.     struct    ifnet *rt_ifp;        /* the answer: interface to use */
  54. };
  55.  
  56. #define    RTF_UP        0x1        /* route useable */
  57. #define    RTF_GATEWAY    0x2        /* destination is a gateway */
  58. #define    RTF_HOST    0x4        /* host entry (net otherwise) */
  59. #define    RTF_DYNAMIC    0x10        /* created dynamically (by redirect) */
  60. #define    RTF_MODIFIED    0x20        /* modified dynamically (by redirect) */
  61.  
  62. /*
  63.  * Routing statistics.
  64.  */
  65. struct    rtstat {
  66.     short    rts_badredirect;    /* bogus redirect calls */
  67.     short    rts_dynamic;        /* routes created by redirects */
  68.     short    rts_newgateway;        /* routes modified by redirects */
  69.     short    rts_unreach;        /* lookups which failed */
  70.     short    rts_wildcard;        /* lookups satisfied by a wildcard */
  71. };
  72.  
  73. #ifdef KERNEL
  74. #define    RTFREE(rt) \
  75.     if ((rt)->rt_refcnt == 1) \
  76.         rtfree(rt); \
  77.     else \
  78.         (rt)->rt_refcnt--;
  79.  
  80. #ifdef    GATEWAY
  81. #define    RTHASHSIZ    64
  82. #else
  83. #define    RTHASHSIZ    8
  84. #endif
  85. #if    (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  86. #define RTHASHMOD(h)    ((h) & (RTHASHSIZ - 1))
  87. #else
  88. #define RTHASHMOD(h)    ((h) % RTHASHSIZ)
  89. #endif
  90. struct    mbuf *rthost[RTHASHSIZ];
  91. struct    mbuf *rtnet[RTHASHSIZ];
  92. struct    rtstat    rtstat;
  93. #endif
  94.